/*
 * putcommand.h
 *
 *  Created on: Nov 16, 2009
 *      Author: kevin
 */

#ifndef PUTCOMMAND_H_
#define PUTCOMMAND_H_

#include "command/command.h"

#include <Poco/File.h>
using Poco::File;

#include "downloadthread.h"
using Commands::DownloadThread;

namespace Commands {

	class PutCommand: public Commands::Command
	{
		public:
			PutCommand( string const& fName, SocketAddress* s = 0);
			virtual ~PutCommand();

			/**
			* Executes the command
			*/
			void execute();

			/**
			* Returns the name by which the command is registered with a CommandFactory
			* @return commandname
			*/
			string name();

			/**
			* Undoes this command, if implemented. If not implemented, throws an NotImplemented excpetion.
			*/
			void undo();

			/**
			* Return a string with which this command can be remade if it were fed into a CommandFactory
			* @return representational string
			*/
			string repr();

			/**
			* Return the creator to make this command given the representational string
			* @return a CommandCreator for this Command
			*/
			CommandCreator creator();
		protected:
			virtual Document* toXML(Document* doc = 0);

		private:
			static Command* makeCommand(string r, void* s);
			static const string NAME;

			string fileName;
			DownloadThread putty;
	};

}

#endif /* PUTCOMMAND_H_ */
